package com.example.happy.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.happy.entity.Account;
import com.example.happy.vo.DataVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AccountMapper extends BaseMapper<Account> {

    @Select("select DATE_FORMAT(t1.create_time, '%Y%m') as name, IFNULL(sum(t1.account_money), 0.00) as value\n" +
            "from t_account t1\n" +
            "WHERE t1.create_time >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH)\n" +
            "and t1.account_type = #{type}\n" +
            "group by DATE_FORMAT(t1.create_time, '%Y%m')")
    List<DataVo> getLineData(@Param("type") int i);

}
